<template>
  <!-- 今日特价 孔德嘉 2023年4月5日20点38分 -->
  <!-- 今日特价 -->
  <div class="now_Day_Cheap">
    <h1
      style="
        text-align: center;
        letter-spacing: 10px;
        font-family: 'Times New Roman', Times, serif;
        font-weight: 400;
        margin: 30px 0 40px 0;
      "
    >
      今日特价&nbsp;&nbsp;心动福利
    </h1>
    <!-- 具体商品 -->
    <div class="cheap_Shop">
      <div
        v-for="(item, index) in cheapShopList"
        :key="index"
        class="cheap_Shop_Item card"
        :style="{ marginRight: (index + 1) % 3 != 0 ? '5%' : '0' }"
        @click="toDIYView(item.id)"
      >
        <div class="card-info">
          <!-- DIy商品图片 -->
          <el-image
            :src="$imageUrl + '?id=' + item.diyImageId"
            class="cheap_Shop_Item_img"
          >
            <div slot="placeholder">
              <Loading></Loading>
            </div>
          </el-image>
          <!-- DIY商品名称  -->
          <div style="width: 200px; margin: 0 auto">
            <p
              style="
                text-align: left;
                margin: 6px 0;
                font-size: 14px;
                overflow: hidden;
                height: 40px;
                line-height: 20px;
                width: 100%;
                font-weight: 700;
              "
            >
              {{ item.diyName }}
            </p>
            <!-- 内容 -->
            <div style="">
              <p
                style="
                text-align: left;
                margin: 0;
                height: 40px;
                line-height: 40px;
                width: 60%; display: inline-block;ver;vertical-align: top;
              "
              >
                <span
                  style="
                    margin-right: 6px;
                    color: #cc3124;
                    font-size: 20px;
                    font-weight: bold;
                    line-height: 0px;
                    margin-top:14px;
                    display: block;
                  "
                  >￥{{ item.diyFavorablePrice }}</span
                >
                <span
                  style="
                    font-size: 12px;
                    color: gray;
                    text-decoration: line-through;
                    font-weight: 400;
                    position: relative;
                    line-height: 0px;
                    top: 0px;
                    left: 2px;
                  "
                  >￥{{ item.diyPrice }}</span
                >
              </p>
              <!-- 抢购 -->
              <div style="width: 40%; display: inline-block">
                <!-- 抢购按钮 -->
                <button class="shopBut">
                  <span>抢</span>
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Loading from "@/components/diy/Loading.vue";
export default {
  name: "NowDayCheap",
  data() {
    return {
      //特价商品
      cheapShopList: [
        //id DIY商品名称 DIY原价 DIY特价 DIY图片链接
      ],
    };
  },
  mounted() {
    this.getHandworkDiyListByOffer();
  },
  components: { Loading },
  methods: {
    // 跳转到DIY商品详情页面
    toDIYView(id) {
      this.$router.push({
        path: "/DIYView",
        query: { diyId: id },
      });
    },
    // 查询DIY的特价商品方法
    getHandworkDiyListByOffer() {
      this.$axios
        .get("/handworkDiy/getHandworkDiyListByOffer")
        .then((res) => {
          // 获取特价商品数据
          this.cheapShopList = res.data.data;
        })
        .catch(() => {
          this.$message.error("获取特价商品失败！");
        });
    },
  },
};
</script>

<style scoped>
/* 特价*/
.cheap_Shop {
  width: 70%;
  margin: 0 auto;
  padding-bottom: 80px;
}
.cheap_Shop_Item {
  display: inline-block;
  width: 30%;
  height: 300px;
  text-align: center;
}
.cheap_Shop_Item_img {
  width: 200px;
  height: 200px;
}
.shopBut {
  display: inline-block;
  border-radius: 4px;
  background-color: #000000;
  border: none;
  font-weight: 700;
  color: #fff200;
  text-align: center;
  font-size: 14px;
  line-height: 40px;
  height: 40px;
  width: calc(100% - 24px);
  transition: all 0.5s;
  cursor: pointer;
}

.shopBut span {
  cursor: pointer;
  display: inline-block;
  position: relative;
  transition: 0.5s;
}

.shopBut span:after {
  content: "»";
  position: absolute;
  opacity: 0;
  top: 0;
  right: -15px;
  transition: 0.5s;
}

.card-info:hover .shopBut span {
  padding-right: 15px;
}

.card-info:hover .shopBut span:after {
  opacity: 1;
  right: 0;
}

.card:hover {
  box-shadow: 0 8px 50px #23232333;
  transform: scale(1.1);
}
.card {
  width: 30%;
  height: 280px;
  background: #f5f5f5;
  padding: 2rem 0;
  border-radius: 10px;
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}
.card-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
</style>